home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / text / misc / MSWordView_src.lha / mswordview / list.c < prev    next >
C/C++ Source or Header  |  1998-12-15  |  25KB  |  972 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include "config.h"
  6. #include "mswordview.h"
  7.  
  8. extern FILE *erroroutput;
  9. extern FILE *outputfile;
  10. extern int inunderline;
  11. extern int newline;
  12. extern int inalist;
  13. extern long int cp;
  14. extern long int realcp;
  15.  
  16.  
  17.  
  18. U16 fail16safe[1] = {0};
  19.  
  20. void get_table_info(FILE *tablefd,list_info *a_list_info,U32 fcSttbFnm,U32 lcbSttbFnm,U32 fcPlcfLst,U32 lcbPlcfLst,U32 fcPlfLfo,U32 lcbPlfLfo, style *sheet)
  21.     {
  22.     U32 i,j;
  23.     int k;
  24.     U16 t;
  25.     U8 len,chplen,paplen,restart,fWord6;
  26.  
  27.     pap listpap;
  28.     int dolvl;
  29.  
  30.     S32 startno;
  31.     int starttype;
  32.  
  33.     U16 temp16=0;
  34.  
  35.     U16 baseistd=1;
  36.  
  37.     U16 level=0;
  38.  
  39.     U16 *list_string=NULL;
  40.  
  41.     U32 absolutehack; 
  42.     int hackflag=1;
  43.     /*this variable is dedicated to Tethys <tethys@ml.com> who found the
  44.     first file to require it*/
  45.  
  46.     list_def *tempdef;
  47.     list_def *tempdef2;
  48.     list_def *defptr=NULL;
  49.  
  50.     chp achp;
  51.  
  52.     a_list_info->array = NULL;
  53.     a_list_info->count= 0;
  54.     a_list_info->lstarray = NULL;
  55.     a_list_info->lstcount= 0;
  56.     a_list_info->o_lst_ids=NULL;
  57.     a_list_info->current_index_nos=NULL;
  58.     a_list_info->o_list_def=NULL;
  59.     a_list_info->level=NULL;
  60.     a_list_info->lst_ids=NULL;
  61.     a_list_info->a_list_def=NULL;
  62.     a_list_info->overridecount=NULL;
  63.  
  64.  
  65.     error(erroroutput,"table names begins at %X, and it %d long",fcSttbFnm,lcbSttbFnm);
  66.     if (lcbSttbFnm !=0)
  67.         {
  68.         fseek(tablefd,fcSttbFnm,SEEK_SET);
  69.  
  70.         for(i=0;i<lcbSttbFnm;i++)
  71.             {
  72.             error(erroroutput,"%x ",getc(tablefd));
  73.             }
  74.         error(erroroutput,"\n"); 
  75.         }
  76.  
  77.     if (lcbPlcfLst!=0)
  78.         {
  79.         error(erroroutput,"table lst begins at %X, and it %d long",fcPlcfLst,lcbPlcfLst);
  80.         fseek(tablefd,fcPlcfLst,SEEK_SET);
  81.  
  82.         a_list_info->lstarray = (U8 *) malloc(lcbPlcfLst);
  83.         if (a_list_info->lstarray == NULL)
  84.             {
  85.             fprintf(erroroutput,"no memory, lp\n");
  86.             exit(-1);
  87.             }
  88.         a_list_info->lstcount = lcbPlcfLst;
  89.         
  90.         a_list_info->nooflsts = read_16ubit(tablefd);
  91.         error(erroroutput,"number of lsts is %d\n",a_list_info->nooflsts);
  92.  
  93.  
  94.         a_list_info->current_index_nos= (int **) malloc(sizeof(int*) * (a_list_info->nooflsts+1));
  95.         if (a_list_info->current_index_nos== NULL)
  96.             {
  97.             fprintf(erroroutput,"no memory here\n");
  98.             exit(-1);
  99.             }
  100.  
  101.         /*make a no of lsts x 9 array which will keep track of what value each
  102.         list is indexed at for each level*/
  103.         for (i=0;i<a_list_info->nooflsts+1;i++)
  104.             {
  105.             a_list_info->current_index_nos[i] = (int *) malloc(sizeof(int) * 9 );
  106.                 {
  107.                 if (a_list_info->current_index_nos[i]== NULL)
  108.                     {
  109.                     fprintf(erroroutput,"no memory here\n");
  110.                     exit(-1);
  111.                     }
  112.                 for (j=0;j<9;j++)
  113.                     a_list_info->current_index_nos[i][j] = -1;
  114.                 }
  115.             }
  116.  
  117.         a_list_info->o_lst_ids = (U32 *) malloc(sizeof(U32) * a_list_info->nooflsts);
  118.         if (a_list_info->o_lst_ids== NULL)
  119.             {
  120.             fprintf(erroroutput,"no memory here\n");
  121.             exit(-1);
  122.             }
  123.         for(k=0;k<a_list_info->nooflsts;k++)
  124.             a_list_info->o_lst_ids[k] = 0;
  125.  
  126.         a_list_info->level = (U8 *) malloc(a_list_info->nooflsts);
  127.         if (a_list_info->level == NULL)
  128.             {
  129.             fprintf(erroroutput,"no memory here\n");
  130.             exit(-1);
  131.             }
  132.  
  133.         i=0;
  134.         k=0;
  135.         while ( (i<lcbPlcfLst-2) && (k <a_list_info->nooflsts) )
  136.             {
  137.             a_list_info->o_lst_ids[k] = read_32ubit(tablefd);
  138.             error(erroroutput,"ID is %x\n",a_list_info->o_lst_ids[k]);
  139.             error(erroroutput,"template ID is %x\n",read_32ubit(tablefd));
  140.             i+=8;
  141.             for(j=0;j<18;j++)
  142.                 {
  143.                 a_list_info->lstarray[j] = getc(tablefd);
  144.                 i++;
  145.                 error(erroroutput,"%x ",a_list_info->lstarray[j]);
  146.                 }
  147.             a_list_info->level[k] = getc(tablefd);
  148.             error(erroroutput,"level flag is %x\n",a_list_info->level[k]);
  149.             a_list_info->level[k] &= 0x01;
  150.             getc(tablefd);
  151.             i+=2;
  152.             k++;
  153.             }
  154.         error(erroroutput,"\n"); 
  155.         a_list_info->a_list_def = (list_def *)malloc(a_list_info->nooflsts*sizeof(list_def));
  156.         if (a_list_info->a_list_def == NULL)
  157.             {
  158.             fprintf(erroroutput,"no memory ppp\n");
  159.             exit(-1);
  160.             }
  161.         for (k=0;k<a_list_info->nooflsts;k++)
  162.             {
  163.             a_list_info->a_list_def[k].sub_def_list=NULL;
  164.             a_list_info->a_list_def[k].len=0;
  165.             a_list_info->a_list_def[k].list_string=NULL;
  166.             }
  167.  
  168.         
  169.  
  170.         error(erroroutput,"table lst begins at %X, ends at %x",fcPlcfLst,fcPlcfLst+lcbPlcfLst);
  171.         error(erroroutput,"but table override begins at %X, and it %d long ends at %x",fcPlfLfo,lcbPlfLfo,fcPlfLfo+lcbPlfLfo);
  172.  
  173.         fseek(tablefd,fcPlcfLst+lcbPlcfLst,SEEK_SET);
  174.  
  175.         /*begin determined with a hex editor*/
  176.         i=0;
  177.         k=0;
  178.         while ( (i<fcPlfLfo-(fcPlcfLst+lcbPlcfLst)) && (k < a_list_info->nooflsts) )
  179.         /*
  180.         while (i<fcPlfLfo-(fcPlcfLst+lcbPlcfLst)) 
  181.         */
  182.             {
  183.             error(erroroutput,"discarding unknown list related data list data");
  184. /*
  185.             startno = getc(tablefd);
  186.             i++;
  187.             error(erroroutput,"start no is %d\n",startno);
  188.  
  189.             for(j=0;j<3;j++)
  190.                 {
  191.                 error(erroroutput,"unknown: %x\n",getc(tablefd));
  192.                 i++;
  193.                 }
  194. */
  195.             startno = (S32) read_32ubit(tablefd);
  196.             error(erroroutput,"start no is %d\n",startno);
  197.             i+=4;
  198.  
  199.             starttype = getc(tablefd);
  200.             i++;
  201.             error(erroroutput,"start type is %d\n",starttype);
  202.             if (starttype == 0)
  203.                 error(erroroutput,"normal type\n");
  204.             else if (starttype == 1)
  205.                 error(erroroutput,"roman type\n");
  206.             else if (starttype == 3)
  207.                 error(erroroutput,"alpha type\n");
  208.  
  209.             restart = getc(tablefd);
  210.             i++;
  211.             fWord6 = restart;
  212.             restart &= 0x10;
  213.             fWord6 &= 0x40;
  214.             if ((fWord6) && (restart))
  215.                 restart=1;
  216.             else
  217.                 restart=0;
  218.             error(erroroutput,"list restart is %d\n",restart);
  219.  
  220.             for(j=0;j<18;j++)
  221.                 {
  222.                 error(erroroutput,"unknown: %x\n",getc(tablefd));
  223.                 i++;
  224.                 }
  225.             
  226.             temp16 = getc(tablefd);
  227.             temp16+=getc(tablefd);
  228.             i+=2;
  229.             error(erroroutput,"len ? %d (%x)\n",temp16,temp16);
  230.             /*
  231.             fill_pap(style *stylelist,int m,int b)
  232.             */
  233.             baseistd = read_16ubit(tablefd);
  234.             error(erroroutput,"base istd ? (%x)\n",baseistd);
  235.             i+=2;
  236.             t=0;
  237.             len = temp16;
  238.             error(erroroutput,"begin LIST PAP/CHP\n");
  239.         
  240.             init_chp(&achp);
  241.  
  242.             while(t<len)
  243.                 {
  244.                 temp16 = read_16ubit(tablefd);
  245.                 t+=2;
  246.                 decode_sprm(tablefd,temp16,&listpap,&achp,NULL,&t,NULL,sheet,baseistd);
  247.                 }
  248.             i+=t;
  249.             temp16 = read_16ubit(tablefd);
  250.             i+=2;
  251.             error(erroroutput,"len of string is %d\n",temp16);
  252.  
  253.             if (i == a_list_info->nooflsts)
  254.                 {
  255.                 error(erroroutput,"oh oh !\n");
  256.                 /* abandon as something has gone wrong, hope for the best*/
  257.                 break;
  258.                 }
  259.             list_string = (U16 *) malloc(sizeof(U16) * (temp16+1));
  260.  
  261.             if (list_string == NULL)
  262.                 {
  263.                 fprintf(erroroutput,"no memory len %d\n",temp16);
  264.                 exit(-1);
  265.                 }
  266.  
  267.             error(erroroutput,"were at %x\n",ftell(tablefd));
  268.  
  269.             /*check the values, if it falls between 0 and 9, then this is the level we're at*/
  270.  
  271.             for (j=0;j<temp16;j++)
  272.                 {
  273.                 list_string[j] = read_16ubit(tablefd);
  274.                 i+=2;
  275.                 }
  276.                 
  277.             list_string[j]='\0';
  278.             for (j=0;j<temp16;j++)
  279.                 error(erroroutput,"%c %x",list_string[j],list_string[j]);
  280.  
  281.  
  282.             if (a_list_info->level[k] == 1)
  283.                 {
  284.                 a_list_info->a_list_def[k].len = temp16;
  285.                 a_list_info->a_list_def[k].begin_no = startno;
  286.                 a_list_info->a_list_def[k].no_type = starttype;
  287.                 a_list_info->a_list_def[k].achp = achp;
  288.                 a_list_info->a_list_def[k].list_string = list_string;
  289.                 a_list_info->a_list_def[k].fPrev= restart;
  290.                 a_list_info->a_list_def[k].sub_def_list=NULL;
  291.                 list_string = NULL;
  292.                 error(erroroutput,"simple list (no %d)\n",k);
  293.                 for (j=0;j<temp16;j++)
  294.                     error(erroroutput,"%c ",a_list_info->a_list_def[k].list_string[j]);
  295.                 defptr=NULL;
  296.                 k++;
  297.                 level=0;
  298.                 }
  299.             else  /*long list*/
  300.                 {
  301.                 error(erroroutput,"complex list (no %d) level %d\n",k,level);
  302.                 if (level == 0)
  303.                     {
  304.                     a_list_info->a_list_def[k].len = temp16;
  305.                     a_list_info->a_list_def[k].begin_no = startno;
  306.                     a_list_info->a_list_def[k].no_type = starttype;
  307.                     a_list_info->a_list_def[k].achp = achp;
  308.                     a_list_info->a_list_def[k].list_string = list_string;
  309.                     a_list_info->a_list_def[k].sub_def_list=NULL;
  310.                     a_list_info->a_list_def[k].fPrev= restart;
  311.                     list_string = NULL;
  312.                     for (j=0;j<temp16;j++)
  313.                         error(erroroutput,"%c ",a_list_info->a_list_def[k].list_string[j]);
  314.                     defptr=NULL;
  315.                     }
  316.                 else
  317.                     {
  318.                     tempdef = (list_def *)malloc(sizeof(list_def));
  319.                     if (tempdef == NULL)
  320.                         {
  321.                         fprintf(erroroutput,"no memory ppp\n");
  322.                         exit(-1);
  323.                         }
  324.                     tempdef->len = temp16;
  325.                     if (tempdef->len == 0)
  326.                         error(erroroutput,"0 len 1\n");
  327.                     tempdef->begin_no = startno;
  328.                     tempdef->no_type = starttype;
  329.                     tempdef->achp = achp;
  330.                     tempdef->fPrev = restart;
  331.                     tempdef->list_string = list_string;
  332.                     tempdef->sub_def_list=NULL;
  333.                     if (level == 1)
  334.                         {
  335.                         a_list_info->a_list_def[k].sub_def_list = tempdef;
  336.                         defptr = a_list_info->a_list_def[k].sub_def_list;
  337.                         }
  338.                     else
  339.                         {
  340.                         if (defptr != NULL)
  341.                             {
  342.                             defptr->sub_def_list = tempdef;
  343.                             defptr =  defptr->sub_def_list;
  344.                             }
  345.                         else
  346.                             {
  347.                             error(erroroutput,"defptr was NULL !!\n");
  348.                             }
  349.                         }
  350.                     tempdef = tempdef->sub_def_list;
  351.                     }
  352.                 level++;
  353.                 if (level == 9) 
  354.                     {
  355.                     k++;
  356.                     level=0;
  357.                     }
  358.                 }
  359.  
  360.             error(erroroutput,"end LIST PAP/CHP\n");
  361.             tempdef=NULL;
  362.             }
  363.         /*end determined with a hex editor*/
  364.         }
  365.  
  366.     fseek(tablefd,fcPlfLfo,SEEK_SET);
  367.  
  368.     error(erroroutput,"fcPlfLfo is %x, ends at %x\n",fcPlfLfo+lcbPlfLfo,fcPlfLfo);
  369.  
  370.     if (lcbPlfLfo !=0)
  371.         {
  372.         fseek(tablefd,fcPlfLfo,SEEK_SET);
  373.  
  374.         a_list_info->array = (U8 *) malloc(lcbPlfLfo);
  375.         if (a_list_info->array == NULL)
  376.             {
  377.             fprintf(erroroutput,"no memory ppsd\n");
  378.             exit(-1);
  379.             }
  380.         a_list_info->count = lcbPlfLfo;
  381.  
  382.         a_list_info->nooflfos=read_32ubit(tablefd);
  383.         error(erroroutput,"there are %ld LFO's\n",a_list_info->nooflfos);
  384.  
  385.  
  386.         a_list_info->lst_ids = (U32 *) malloc(sizeof(U32) * a_list_info->nooflfos);
  387.         if (a_list_info->lst_ids== NULL)
  388.             {
  389.             fprintf(erroroutput,"no memory opo\n");
  390.             exit(-1);
  391.             }
  392.  
  393.         a_list_info->overridecount = (int *) malloc(sizeof(int) * a_list_info->nooflfos);
  394.         if (a_list_info->overridecount == NULL)
  395.             {
  396.             fprintf(erroroutput,"no memory opo\n");
  397.             exit(-1);
  398.             }
  399.  
  400.         a_list_info->o_list_def = (list_def *)malloc(a_list_info->nooflfos*sizeof(list_def));
  401.         if (a_list_info->o_list_def == NULL)
  402.             {
  403.             fprintf(erroroutput,"scream\n");
  404.             exit(-1);
  405.             }
  406.  
  407.         for(i=0;i<a_list_info->nooflfos;i++)
  408.             {
  409.             a_list_info->lst_ids[i] = read_32ubit(tablefd);
  410.             error(erroroutput,"IDHERE-->%x \n",a_list_info->lst_ids[i]);
  411.             for (j=0;j<8;j++)
  412.                 error(erroroutput,"LFO:undoc %x\n",getc(tablefd));
  413.             a_list_info->overridecount[i] = getc(tablefd);
  414.             error(erroroutput,"is there a lfovl ? %d\n",a_list_info->overridecount[i]);
  415.  
  416.             k=0;
  417.             while(k<a_list_info->nooflsts)
  418.                 {
  419.                 if (a_list_info->lst_ids[i]  == a_list_info->o_lst_ids[k])
  420.                     break;
  421.                 k++;
  422.                 }
  423.  
  424.             if (a_list_info->overridecount[i] > 0)
  425.                 {
  426.                 error(erroroutput,"create a copy\n");
  427.                 /*
  428.                 a_list_info->o_list_def[i] = (list_def *) malloc(sizeof(list_def));
  429.                 */
  430.                 tempdef = &(a_list_info->o_list_def[i]);
  431.                 tempdef2 = &(a_list_info->a_list_def[k]);
  432.  
  433.                 if ((tempdef == NULL) || (tempdef2 == NULL))
  434.                     {
  435.                     fprintf(erroroutput,"list problem 2\n");
  436.                     return;
  437.                     }
  438.  
  439.                 do
  440.                     {
  441.                     tempdef->len =  tempdef2->len;
  442.                     if (tempdef->len == 0)
  443.                         error(erroroutput,"0 len 2\n");
  444.                     else
  445.                         error(erroroutput,"lsn is %d\n",tempdef->len);
  446.                     tempdef->begin_no = tempdef2->begin_no;
  447.                     tempdef->no_type =  tempdef2->no_type;
  448.                     tempdef->achp = tempdef2->achp;
  449.                     tempdef->fPrev = tempdef2->fPrev;
  450.                     tempdef->list_string = (U16 *) malloc(sizeof(U16) * (tempdef2->len+1));
  451.                     if (tempdef->list_string != NULL)
  452.                         {
  453.                         for (j=0;j<tempdef->len;j++)
  454.                             {
  455.                             if (j==tempdef2->len)
  456.                                 {
  457.                                 error(erroroutput,"overran string len %d, somthings wrong!\n",tempdef2->len);
  458.                                 if (tempdef2->len == 0)
  459.                                     {
  460.                                     fprintf(erroroutput,"somehow len was 0\n");
  461.                                     tempdef2->list_string=(U16*) malloc(sizeof(U16));
  462.                                     tempdef2->list_string[0] = '\0';
  463.                                     }
  464.                                 break;
  465.                                 }
  466.                             tempdef->list_string[j] = tempdef2->list_string[j];
  467.                             }
  468.                         tempdef->list_string[j] = '\0';
  469.                         }
  470.  
  471.                     if (tempdef2->sub_def_list != NULL)
  472.                         tempdef->sub_def_list = (list_def *) malloc(sizeof(list_def));
  473.                     else
  474.                         tempdef->sub_def_list= NULL;
  475.                     tempdef = tempdef->sub_def_list;
  476.                     tempdef2 = tempdef2->sub_def_list;
  477.                     }
  478.                 while(tempdef2 != NULL);
  479.  
  480.                 }
  481.             else
  482.                 {
  483.                 a_list_info->o_list_def[i] = a_list_info->a_list_def[k];
  484.                 error(erroroutput,"linking lfo id %x %d to lst id %x %d\n",a_list_info->lst_ids[i],i,a_list_info->o_lst_ids,k);
  485.                 }
  486.             for (j=0;j<3;j++)
  487.                 error(erroroutput,"LFO:undoc %x\n",getc(tablefd));
  488.             }
  489.  
  490.  
  491.         error(erroroutput,"---->nooflfos is %d, nooflsts is %d,table offset is %x\n",a_list_info->nooflfos,a_list_info->nooflsts,ftell(tablefd));
  492. /*
  493.         for(i=0;i<a_list_info->nooflfos;i++)
  494. */
  495.         for(i=0;i<a_list_info->nooflsts;i++)
  496.             {
  497.             if (a_list_info->overridecount[i] > 0)
  498.                 {
  499. #if 0
  500.                 fprintf(stderr,"sample ffffffff doc\n");
  501. #endif
  502. #if 0
  503.                 do
  504.                     {
  505.                     absolutehack = read_32ubit(tablefd); 
  506.                     /*
  507.                     what the hell is this ????, dont know where it 
  508.                     comes from, im not sure *what* is going on here.
  509.                     just that theres from one ffffffff to two ffffffff 
  510.                     sets that are showing up for no reason that i understand.
  511.                     im ignoring them for now, maybe they mean to skip a level.
  512.                     maybe they mean something else. 
  513.                     */
  514.                     error(erroroutput,"absolute hack = %x\n",absolutehack);
  515.                     }
  516.                 while(absolutehack == 0xffffffffUL);
  517. #endif
  518.  
  519.                 /*
  520.                 the reasoning here is quite poor, but basically
  521.                 im running on the theory that ffffffff is a flag
  522.                 that tells us when to begin using the lfovls
  523.                 */
  524.                 absolutehack = read_32ubit(tablefd); 
  525.                 if (absolutehack == 0xffffffffUL)
  526.                     {
  527.                     hackflag=0;
  528.                     continue;
  529.                     }
  530.                 else if (hackflag==1)
  531.                     continue;
  532.                     
  533.                 fseek(tablefd,-4,SEEK_CUR);
  534.  
  535.                 error(erroroutput,"sitting at %x\n",ftell(tablefd));
  536.  
  537.                 error(erroroutput,"startat etc ? is %x\n",read_32ubit(tablefd));
  538.                 len = getc(tablefd);
  539.                 tempdef2 = &(a_list_info->o_list_def[i]);
  540.                 error(erroroutput,"overrode level is %d\n",len & 0x0F);
  541.                 k = len & 0x0F;
  542.                 j=0;
  543.                 while(j < k)
  544.                     {
  545.                     if (tempdef2->sub_def_list != NULL)
  546.                         tempdef2 = tempdef2->sub_def_list;
  547.                     else
  548.                         error(erroroutput,"oh oh fell off end\n");
  549.                     j++;
  550.                     }
  551.  
  552.                 error(erroroutput,"following LVL is %d\n",len & 0x20);
  553.                 dolvl = len & 0x10;
  554.                 len = len &= 0x01;
  555.                 for (j=0;j<3;j++)
  556.                     {
  557.                     error(erroroutput,"reserved %c\n",getc(tablefd));
  558.                     }
  559.                 error(erroroutput,"onto lvl\n");
  560.                 tempdef2->begin_no = read_32ubit(tablefd);
  561.                 tempdef2->no_type = getc(tablefd);
  562.  
  563.                 restart = getc(tablefd);
  564.                 fWord6 = restart;
  565.                 restart &= 0x10;
  566.                 fWord6 &= 0x40;
  567.                 if ((fWord6) && (restart))
  568.                     tempdef2->fPrev=1;
  569.  
  570.                 j+=6;
  571.                 for (j=0;j<18;j++)
  572.                     error(erroroutput,"temp unused %c\n",getc(tablefd));
  573.  
  574.                 chplen = getc(tablefd);
  575.                 error(erroroutput,"chp len is %d\n",chplen);
  576.                 paplen  = getc(tablefd);
  577.                 error(erroroutput,"pap len is %d\n",paplen);
  578.                 read_16ubit(tablefd);
  579.                 error(erroroutput,"sitting at %x\n",ftell(tablefd));
  580.  
  581.  
  582.                 error(erroroutput,"id is %x, adding to number %d\n",a_list_info->o_lst_ids[i],i);
  583.                 t=0;
  584.                 while(t<paplen+chplen)
  585.                     {
  586.                     temp16 = read_16ubit(tablefd);
  587.                     t+=2;
  588.                     /*ignore pap here*/
  589.                     decode_sprm(tablefd,temp16,&listpap,&(tempdef2->achp),NULL,&t,NULL,sheet,baseistd);
  590.                     }
  591.                 tempdef2->len = read_16ubit(tablefd);
  592.                 error(erroroutput,"following string is %d long\n",tempdef2->len);
  593.                 if (tempdef2->list_string != NULL)
  594.                     free(tempdef2->list_string);
  595.                 tempdef2->list_string = (U16*) malloc(sizeof(U16) * (tempdef2->len+1));
  596.                 for (k=0;k<tempdef2->len;k++)
  597.                     {
  598.                     tempdef2->list_string[k] = read_16ubit(tablefd);
  599.                     error(erroroutput,"str char ? -->%x\n",tempdef2->list_string[k]);
  600.                     }
  601.                 tempdef2->list_string[k] = '\0';
  602.                 }
  603.             }
  604.         error(erroroutput,"\n"); 
  605.         }
  606.     }
  607.  
  608. void decode_e_list(pap *apap,chp *achp,list_info *a_list_info)
  609.     {
  610.     int i;
  611.     int lvl;
  612.     if ( (apap->ilvl+1) < inalist)
  613.         {
  614.         error(erroroutput,"ILVL: apap->ilvl+1 id %d inalist is %d\n",(apap->ilvl+1),inalist);
  615. /*
  616.         if (apap->ilvl+1 == 0)
  617.             lvl = 1;
  618.         else
  619. */
  620.             lvl = apap->ilvl+1;
  621.  
  622.         for(i=inalist;i>lvl;i--)
  623.             {
  624.             /*
  625.             if (i==1)
  626.                 fprintf(outputfile,"\n<!--</DIR>-->");
  627.             else
  628.                 fprintf(outputfile,"\n</DIR>");
  629.             */
  630.             }
  631.         inalist=apap->ilvl+1;
  632.         }
  633.     }
  634.     
  635.  
  636. void decode_list_level(pap *apap,int inalist,int num)
  637.     {
  638.     int i;
  639.     if (apap->ilvl+1 != 0)
  640.         {
  641.         error(erroroutput,"List stuff inalist is %d\n, ilvl+1 is %d\n",inalist,apap->ilvl+1);
  642.         if (apap->ilvl+1 == inalist)
  643.             {
  644.             if (apap->ilvl+1 != 1)
  645.                 {
  646.                 /*
  647.                 fprintf(outputfile,"\n</DIR>\n");
  648.                 fprintf(outputfile,"\n<dir>\n");
  649.                 */
  650.                 }
  651.             else
  652.                 {
  653.                 /*
  654.                 if (num == IGNOREALL)
  655.                     fprintf(outputfile,"\n</fake DIR>\n<fake DIR>\n");
  656.                 else
  657.                     fprintf(outputfile,"\n<!--</DIR>\n<dir>-->\n");
  658.                 */
  659.  
  660.                 }
  661.             }
  662.         else
  663.             {
  664.             for(i=inalist;i<apap->ilvl+1;i++)
  665.                 {
  666.                 if (i==0)
  667.                     {
  668.                     if (num == IGNOREALL)
  669.                         fprintf(outputfile,"\nfake DIR>\n");
  670.                         /*
  671.                     else
  672.                         fprintf(outputfile,"\n<!--<dir>-->\n");
  673.                         */
  674.                     }
  675.                 else
  676.                     fprintf(outputfile,"\n<DIR>");
  677.                 }
  678.             }
  679.         }
  680.     inalist = apap->ilvl+1;
  681.     for(i=1;i<inalist;i++)
  682.         {
  683.         if (inunderline)
  684.             fprintf(outputfile,"</u>");
  685.         fprintf(outputfile,"    ");
  686.         if (inunderline)
  687.             fprintf(outputfile,"<u>");
  688.         }
  689.     }
  690.  
  691. void decode_s_anld(pap *apap,chp *achp,list_info *a_list_info,ffn *fontnamelist)
  692.     {
  693.     int i;
  694.     int issection;
  695.     
  696.     chp anldchp;
  697.  
  698.     error(erroroutput,"ilvl is %d\n",apap->ilvl);
  699.  
  700.     if ( ( (apap->ilvl+1) > inalist)  /*|| (tempid)*/ )
  701.         {
  702.         error(erroroutput,"ANLD: new one is %d",apap->ilvl+1);
  703.         decode_list_level(apap,0,DONTIGNORENUM);
  704.  
  705.         /*if we are at a sub level i.e > 0, then */
  706.         error(erroroutput,"the ilfo to use is %d\n",apap->ilfo);
  707.  
  708.         inalist=apap->ilvl+1;
  709.         }
  710.  
  711.     if ( (apap->ilvl) != -1)
  712.         {
  713.         if ( (apap->ilfo > -1) && (newline))
  714.             {
  715.             fprintf(outputfile,"\n");
  716.  
  717.             anldchp = *achp;
  718.             if (apap->anld.fSetBold)
  719.                 if (apap->anld.flags2&0x08)
  720.                     anldchp.fBold =1;
  721.             if (apap->anld.fSetItalic)
  722.                 if (apap->anld.flags2&0x10)
  723.                     anldchp.fItalic=1;
  724.             if (apap->anld.flags2&0x02)
  725.                     anldchp.underline = apap->anld.flags3&0x07;
  726.             anldchp.ascii_font = apap->anld.ftc;
  727.             anldchp.eastfont = apap->anld.ftc;
  728.             anldchp.noneastfont =apap->anld.ftc;
  729.             anldchp.fontsize = apap->anld.hps;
  730.  
  731.             i=0;
  732.             while(i<apap->anld.cxchTextBefore)
  733.                 {
  734.                 error(erroroutput,"list string-->%d %c\n",apap->anld.rgxch[i],apap->anld.rgxch[i]);
  735.                 if (apap->anld.rgxch[i] == '*')
  736.                     fprintf(outputfile,"<img src=\"%s/%d.gif\">",symbolfontdir(),151);
  737.                 else
  738.                     {
  739.                     decode_letter(apap->anld.rgxch[i],0,apap,&anldchp,NULL,NULL,NULL,fontnamelist,NULL,NULL,&issection);
  740.                     realcp--;
  741.                     cp--;
  742.                     }
  743.                 i++;
  744.                 }
  745.  
  746.             error(erroroutput,"numbering type is %d\n",apap->anld.nfc);
  747.             /*
  748.             decode_list_nfc(&(listvalue[apap->ilvl]),apap->anld.nfc);
  749.             */
  750.             decode_list_nfc(&(a_list_info->current_index_nos[apap->ilfo][apap->ilvl]),apap->anld.nfc);
  751.  
  752.             i=apap->anld.cxchTextBefore;
  753.             while(i<apap->anld.cxchTextAfter)
  754.                 {
  755.                 error(erroroutput,"list string-->%d %c\n",apap->anld.rgxch[i],apap->anld.rgxch[i]);
  756.                 if (apap->anld.rgxch[i] == '*')
  757.                     fprintf(outputfile,"<img src=\"%s/%d.gif\">",symbolfontdir(),151);
  758.                 else
  759.                     {
  760.                     decode_letter(apap->anld.rgxch[i],0,apap,NULL,NULL,NULL,NULL,fontnamelist,NULL,NULL,&issection);
  761.                     realcp--;
  762.                     cp--;
  763.                     }
  764.                 i++;
  765.                 }
  766.  
  767.             fprintf(outputfile," ");
  768.             newline=0;
  769.             }
  770.         }
  771.     }
  772. /*
  773. ok im going out on a limb here and see does this fit the realworld: heres the hack
  774. sections titles have the section number prepended to them, now the 0x0c is use like
  775. i would expect it to be, *only* that after this mark sections are also considered list 
  776. elements with links to listdata which contain a mark for a number to be used, 
  777. with my logic i get
  778. <section no> <list number> <the rest of list data e.g. "."> Section Name
  779. other logic gave
  780. <list number> <the rest of list data e.g. "."> <section no> Section Name
  781.  
  782. what ms gives is
  783.  
  784. <section no> <the rest of list data e.g. "."> Section Name
  785.  
  786. so if i have a 0x0c 
  787.  
  788. CHOP CHOP CHOP, all wrong, talking out my bum, solution is in CHANGELOG for 
  789. version 0.2.1, in fact the section break has NOTHING to do with it, its part
  790. of a wierd mechanism with dummy list elements, im dead proud i figured it out.
  791. */
  792.  
  793.  
  794. void decode_s_list(pap *apap,chp *achp,list_info *a_list_info,ffn *fontnamelist,int num)
  795.     {
  796.     /*
  797.     U32 tempid=0;
  798.     */
  799.     int i,j,k,p;
  800.     int index;
  801.     int fPrev;
  802.  
  803.     int issection;/*dummy*/
  804.     
  805.     list_def *list_data=NULL;
  806.     list_def *flist_data=NULL;
  807.     list_def *plist_data=NULL;
  808.  
  809.     error(erroroutput,"doing start list\n");
  810.  
  811.     if (apap->ilfo == 2047)
  812.         {
  813.         error(erroroutput,"special ilfo, doing an anld\n");
  814.         decode_s_anld(apap,achp,a_list_info,fontnamelist);
  815.         return;
  816.         }
  817.     
  818.     if (apap->ilfo > -1) 
  819.         {
  820.         index = decode_ilfo(apap,a_list_info);
  821.         if (index == -1)
  822.             {
  823.             error(erroroutput,"invalid ilfo index\n");
  824.             return;
  825.             }
  826.  
  827.         if ( ( (apap->ilvl+1) > inalist) )
  828.             {
  829.             error(erroroutput,"ILVL: incoming indent level %d new one is %d",inalist,apap->ilvl+1);
  830.  
  831.             if (num == IGNOREALL)
  832.                 fprintf(outputfile,"\n<!--tricky old ms, hidden list values here\n");
  833.  
  834.             /*if we are at a sub level i.e > 0, then */
  835.             error(erroroutput,"the ilfo to use is %d\n",apap->ilfo);
  836.  
  837.             flist_data = apap->list_data;
  838.             
  839.             i=0;
  840.             while ( (i<apap->ilvl) && (flist_data->sub_def_list != NULL) )
  841.                 {
  842.                 error(erroroutput,"1 indenting into structure\n");
  843.                 flist_data = flist_data->sub_def_list;
  844.                 i++;
  845.                 }
  846.     
  847.             if (a_list_info->current_index_nos[index][apap->ilvl]==-1)
  848.                 {
  849.                 /*new list, start again*/
  850.                 plist_data = flist_data;
  851.                 for (p=apap->ilvl;p<9;p++)
  852.                     {
  853.                     if (plist_data != NULL)
  854.                         {
  855.                         a_list_info->current_index_nos[index][p]=plist_data->begin_no;
  856.                         plist_data = plist_data->sub_def_list;
  857.                         }
  858.                     }
  859.                 }
  860.             inalist=apap->ilvl+1;
  861.             }
  862.         else
  863.             flist_data = apap->list_data;
  864.  
  865.         if ( (apap->ilvl) != -1)
  866.             {
  867.             error(erroroutput,"list stage 1\n");
  868.             if ( (apap->ilfo > -1) && (newline))
  869.                 {
  870.                 error(erroroutput,"list stage 2\n");
  871.                 if (apap->list_data != NULL)
  872.                     {
  873.                     j=0;
  874.                     list_data = apap->list_data;
  875.                     fPrev = flist_data->fPrev;
  876.                     do
  877.                         {
  878.                         error(erroroutput,"list stage 3\n");
  879.                         if (list_data->len > 0)
  880.                             {
  881.                             error(erroroutput,"list stage 4\n");
  882.                             i=0;
  883.                             
  884.                             if ( ((!fPrev) && (j == apap->ilvl)) || (fPrev) )
  885.                                 {
  886.                                 if (flushbreaks(0))
  887.                                     {
  888.                                     error(erroroutput,"<!--new paragraph-->");
  889.                                     do_indent(apap);
  890.                                     }
  891.                                 fprintf(outputfile,"\n");
  892.                                 decode_list_level(apap,inalist,num);
  893.                                 while ( i<list_data->len )
  894.                                     {
  895.                                     error(erroroutput,"list string-->%d %c\n",list_data->list_string[i],list_data->list_string[i]);
  896.                                     if (list_data->list_string[i] <= 9)
  897.                                         {
  898.                                         flist_data = apap->list_data;
  899.                                         k=0;
  900.                                         while(k<list_data->list_string[i])    
  901.                                             {
  902.                                             flist_data = flist_data->sub_def_list;
  903.                                             if (flist_data == NULL)
  904.                                                 {
  905.                                                 fprintf(erroroutput,"list problem 2\n");
  906.                                                 return;
  907.                                                 }
  908.                                             k++;
  909.                                             }
  910.                                         error(erroroutput,"numbering type is %d\n",flist_data->no_type);
  911.  
  912.                                         if (a_list_info->current_index_nos[index][k]==-1)
  913.                                             {
  914.                                             /*new list, start again*/
  915.                                             plist_data = flist_data;
  916.                                             for (p=k;p<9;p++)
  917.                                                 {
  918.                                                 if (plist_data != NULL)
  919.                                                     {
  920.                                                     a_list_info->current_index_nos[index][p]=plist_data->begin_no;
  921.                                                     plist_data = plist_data->sub_def_list;
  922.                                                     }
  923.                                                 }
  924.                                         /*    
  925.                                             a_list_info->current_index_nos[index][k]=flist_data->begin_no;
  926.                                         */
  927.                                             
  928.                                             }
  929.                                         else if (k!=j)
  930.                                             a_list_info->current_index_nos[index][k]--;
  931.                                         decode_list_nfc(&(a_list_info->current_index_nos[index][k]),flist_data->no_type);
  932.                                         
  933.                                         plist_data = flist_data->sub_def_list;
  934.                                         for (p=j+1;p<9;p++)
  935.                                             {
  936.                                             if (plist_data != NULL)
  937.                                                 {
  938.                                                 a_list_info->current_index_nos[index][p]=plist_data->begin_no;
  939.                                                 plist_data = plist_data->sub_def_list;
  940.                                                 }
  941.                                             }
  942.                                         
  943.                                         }
  944.                                     else if (list_data->list_string[i] == '*')
  945.                                         fprintf(outputfile,"<img src=\"%s/%d.gif\">",symbolfontdir(),151);
  946.                                     else
  947.                                         {
  948.                                         decode_letter(list_data->list_string[i],0,apap,&(list_data->achp),NULL,NULL,NULL,fontnamelist,NULL,NULL,&issection);
  949.                                         realcp--;
  950.                                         cp--;
  951.                                         }
  952.                                     i++;
  953.                                     }
  954.                                     
  955.                                 fprintf(outputfile," ");
  956.                                 newline=0;
  957.                                 }
  958.                             }    
  959.                         list_data = list_data->sub_def_list;
  960.                         j++;
  961.                         }
  962.                     while ( (j<apap->ilvl+1)  && (list_data != NULL) );
  963.                     }
  964.                     
  965.                     
  966.                 }
  967.             if (num == IGNOREALL)
  968.                 fprintf(outputfile,"\n-->\n");
  969.             }
  970.         }
  971.     }
  972.